package com.xiaolin.structure.linked.bothway.loop;

/**
 * @ClassName BothWayLoopLinkedListTest
 * @Description 描述
 * @Detail detail
 * @Author MyPC
 * @Date 2020/12/12
 * @Version 1.0
 */
public class BothWayLoopLinkedListTest {
    public static void main(String[] args) {
        BothWayLoopLinkedList<Student> loopLinkedList=new BothWayLoopLinkedList<>();
        loopLinkedList.add(new Student(1));
        loopLinkedList.add(new Student(2));
        loopLinkedList.add(new Student(3));
        System.out.println(loopLinkedList.first);
        System.out.println(loopLinkedList.first.pre);
        System.out.println(loopLinkedList.first.next);
        System.out.println(loopLinkedList.last.pre);
        System.out.println(loopLinkedList.getElement(2).age);
//        System.out.println("移除第一个节点");
//        loopLinkedList.remove(0);
//        System.out.println(loopLinkedList.size());
//        System.out.println(loopLinkedList.first);
//        System.out.println(loopLinkedList.first.pre);
//        System.out.println(loopLinkedList.last.next);
//        System.out.println("移除最后一个节点");
//        loopLinkedList.remove(2);
//        System.out.println(loopLinkedList.size());
//        System.out.println(loopLinkedList.last);
//        System.out.println(loopLinkedList.last.next);
//        System.out.println(loopLinkedList.first.pre);
        System.out.println("移除中间节点");
        loopLinkedList.remove(1);
        System.out.println(loopLinkedList.size());
        System.out.println(loopLinkedList.first);
        System.out.println(loopLinkedList.last);
        System.out.println(loopLinkedList.first.next);
        System.out.println(loopLinkedList.last.pre);
    }

    /**
     * @ClassName Student
     * @Description 节点数据
     * @Detail detail
     * @Author MyPC
     * @Date 2020/11/5
     * @Version 1.0
     */
    static class Student{
        int age;

        public Student(int age){
            this.age=age;
        }

        public void setAge(int age) {
            this.age = age;
        }
    }
}
